import { listDeviceModel } from '@/apis/asset/common'
import { ref } from 'vue'

/** 设备品牌模块 */
export function deviceModel(options?: { onSuccess?: () => void }) {
  const loading = ref(false)
  const deviceModelList = ref([{}])

  const getDeviceModelList = async (categoryId?: string) => {
    try {
      loading.value = true
      const res = await listDeviceModel({ categoryId: categoryId })
      const data = res.data;
      deviceModelList.value = data.map(item => {
        return {
          label: item,
          value: item
        };
      });
      options?.onSuccess && options.onSuccess()
    } finally {
      loading.value = false
    }
  }
  return { deviceModelList, getDeviceModelList, loading }
}
